import sys
import readline
from lib import cfclib


class CliClient():
    """
    This class is the client class that handles the main program and user input
    """

    cli = cfclib.CloudFilesCli()


    def check_input(self, string):

        if 'list objects' in string:
            self.cli.list_container_objects()
        elif 'upload' in string:
            self.cli.upload_object()
        elif 'set container' in string:
            self.cli.get_container_name()
        elif 'create container' in string:
            self.cli.create_container()
        elif 'list containers' in string:
            self.cli.list_containers()
        elif 'delete container' in string:
            self.cli.delete_container()
        elif 'delete object' in string:
            self.cli.delete_object()
        elif 'dump vars' in string:
            self.cli.dump_variables()
        elif 'connect' in string:
            self.cli.get_connection()
        elif 'quit' in string or 'exit' in string:
            sys.exit()


    def run(self):
        self.cli.get_connection()
        while 1:
            input = raw_input("cfcli> ")
            self.check_input(input)



def main():
    client = CliClient()
    client.run()


if __name__ == "__main__":
    main()
